﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:c="clr-namespace:personalplaner.common.controls"
                    xmlns:k="clr-namespace:personalplaner.common.themes">

    <!--<ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/Sage200.X3connect.Core;component/Resources/CommonStyles.xaml"/>
    </ResourceDictionary.MergedDictionaries>-->

    <Style TargetType="{x:Type c:MenuButton}">
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <!--<Setter Property="Foreground" Value="#90FFFFFF"/>-->
        <Setter Property="Foreground" Value="{DynamicResource {x:Static k:ResourceKeys.ForegroundBrush}}"/>
        <Setter Property="FontSize" Value="11"/>
        <Setter Property="FontWeight" Value="Heavy"/>
        <!--<Setter Property="VerticalAlignment" Value="Top"/>-->
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type  c:MenuButton}" >
                    <Border 
						x:Name="PART_ButtonBorder" BorderThickness="1" VerticalAlignment="Top" SnapsToDevicePixels="True">
                        <Border.Background>
                            <SolidColorBrush Color="Transparent" x:Name="stop1"/>
                            <!--<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                <LinearGradientBrush.GradientStops>
                                    <GradientStop x:Name="stop1" Color="Transparent" Offset="0"/>
                                    <GradientStop x:Name="stop2" Color="Transparent" Offset="0.4"/>
                                    <GradientStop x:Name="stop3" Color="Transparent" Offset="0.4"/>
                                    <GradientStop x:Name="stop4" Color="Transparent" Offset="1"/>
                                </LinearGradientBrush.GradientStops>
                            </LinearGradientBrush>-->
                        </Border.Background>
                        <Border.BorderBrush>
                            <SolidColorBrush x:Name="BorderBrush" Color="Transparent"/>
                        </Border.BorderBrush>
                        <Grid>
                            <Grid Margin="5,2,5,2">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>

                                <ContentPresenter x:Name="Icon"
                                                    Margin="3,0,3,0"
													VerticalAlignment="Center"
													ContentSource="Icon"
                                                    HorizontalAlignment="Center"
													SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>

                                <ContentControl Grid.Column="1" Foreground="{TemplateBinding Foreground}" FontSize="{TemplateBinding FontSize}" FontWeight="{TemplateBinding FontWeight}" Margin="2,0,2,0" VerticalAlignment="Center" >
                                    <ContentPresenter x:Name="Text" ContentSource="Text" HorizontalAlignment="Left" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                </ContentControl>

                                <Path Name="Arrow" Margin="4,0,0,0"  Grid.Column="2" HorizontalAlignment="Left" VerticalAlignment="Center" Data="M 0 0 L 4 5 L 8 0 Z" Fill="{TemplateBinding Foreground}" />
                                <!--Fill="Gray" Data="M 0 0 L 3 7 L 6 0 Z"-->
                                
                            </Grid>

                            <Popup x:Name="PART_Popup" StaysOpen="False" PlacementTarget="{Binding ElementName=PART_ButtonBorder}" Margin="0,5,0,0" Placement="Bottom" HorizontalAlignment="Right" AllowsTransparency="True">
                                <!--<Border Background="#ABACAC" BorderBrush="Black" BorderThickness="1" Margin="0,5,0,5" CornerRadius="2" >-->
                                <Border Background="{DynamicResource {x:Static k:ResourceKeys.MenuButtonDropDownBackgroundBrush}}" BorderBrush="Black" BorderThickness="1" Margin="0,5,0,5" CornerRadius="2" >
                                    <ContentPresenter HorizontalAlignment="Center" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                                </Border>
                            </Popup>

                        </Grid>
                    </Border>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <!--<Setter Property="BorderThickness" Value="1,0,0,0" TargetName="PART_PopupButtonBorder"/>-->

                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ColorAnimation Storyboard.TargetName="stop1" Storyboard.TargetProperty="Color" Duration="0:0:0.15" To="#18000000"/>
                                        <ColorAnimation Storyboard.TargetName="BorderBrush" Storyboard.TargetProperty="Color" Duration="0:0:0.10" To="#60000000"/>
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ColorAnimation Storyboard.TargetName="stop1" Storyboard.TargetProperty="Color" Duration="0:0:0.15" />
                                        <ColorAnimation Storyboard.TargetName="BorderBrush" Storyboard.TargetProperty="Color" Duration="0:0:0.10" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                            <!--<Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ColorAnimation Storyboard.TargetName="stop1" Storyboard.TargetProperty="Color" Duration="0:0:0.25" To="#FFDDF5FF"/>
                                        <ColorAnimation Storyboard.TargetName="stop2" Storyboard.TargetProperty="Color" Duration="0:0:0.25" To="#FFD6F3FF"/>
                                        <ColorAnimation Storyboard.TargetName="stop3" Storyboard.TargetProperty="Color" Duration="0:0:0.25" To="LightBlue"/>
                                        <ColorAnimation Storyboard.TargetName="stop4" Storyboard.TargetProperty="Color" Duration="0:0:0.25" To="LightBlue"/>
                                        <ColorAnimation Storyboard.TargetName="BorderBrush" Storyboard.TargetProperty="Color" Duration="0:0:0.15" To="#FF7DA2CE"/>
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ColorAnimation Storyboard.TargetName="stop1" Storyboard.TargetProperty="Color" Duration="0:0:0.25" />
                                        <ColorAnimation Storyboard.TargetName="stop2" Storyboard.TargetProperty="Color" Duration="0:0:0.25" />
                                        <ColorAnimation Storyboard.TargetName="stop3" Storyboard.TargetProperty="Color" Duration="0:0:0.25" />
                                        <ColorAnimation Storyboard.TargetName="stop4" Storyboard.TargetProperty="Color" Duration="0:0:0.25" />
                                        <ColorAnimation Storyboard.TargetName="BorderBrush" Storyboard.TargetProperty="Color" Duration="0:0:0.15" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>-->
                            <!--<Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ColorAnimation Storyboard.TargetName="stop1" Storyboard.TargetProperty="Color" Duration="0:0:0.25" To="#20FFEA96"/>
                                        <ColorAnimation Storyboard.TargetName="stop2" Storyboard.TargetProperty="Color" Duration="0:0:0.25" To="#FDFADE"/>
                                        <ColorAnimation Storyboard.TargetName="stop3" Storyboard.TargetProperty="Color" Duration="0:0:0.25" To="#FFEA96"/>
                                        <ColorAnimation Storyboard.TargetName="stop4" Storyboard.TargetProperty="Color" Duration="0:0:0.25" To="#20FFEA96"/>
                                        <ColorAnimation Storyboard.TargetName="BorderBrush" Storyboard.TargetProperty="Color" Duration="0:0:0.15" To="Goldenrod"/>
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ColorAnimation Storyboard.TargetName="stop1" Storyboard.TargetProperty="Color" Duration="0:0:0.25" />
                                        <ColorAnimation Storyboard.TargetName="stop2" Storyboard.TargetProperty="Color" Duration="0:0:0.25" />
                                        <ColorAnimation Storyboard.TargetName="stop3" Storyboard.TargetProperty="Color" Duration="0:0:0.25" />
                                        <ColorAnimation Storyboard.TargetName="stop4" Storyboard.TargetProperty="Color" Duration="0:0:0.25" />
                                        <ColorAnimation Storyboard.TargetName="BorderBrush" Storyboard.TargetProperty="Color" Duration="0:0:0.15" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>-->

                        </Trigger>

                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Text}" Value="">
                            <Setter Property="Visibility" TargetName="Text" Value="Collapsed"/>
                            <Setter Property="Margin" TargetName="Text" Value="0"/>
                        </DataTrigger>

                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Content}" Value="{x:Null}">
                            <!--<Setter Property="Visibility" TargetName="PART_PopupButtonBorder" Value="Collapsed"/>-->
                            <Setter Property="Visibility" TargetName="Arrow" Value="Collapsed"/>
                        </DataTrigger>

                        <!--Style form images. Sets the transparency of the image to 50% if the button containing it is disabled-->
                        <!--Small workaround to display disabled images in buttons-->
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsEnabled}" Value="False">
                            <Setter Property="Opacity" Value="0.50" TargetName="Icon"/>
                            <Setter Property="Opacity" Value="0.50" TargetName="Text"/>
                            <Setter Property="Opacity" Value="0.50" TargetName="Arrow"/>
                        </DataTrigger>

                    </ControlTemplate.Triggers>

                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
</ResourceDictionary>